<?php

/**
 * Description of User
 *
 * @author Admin
 */
class Main_Resource_User extends WOW_Model_Resource_Db_Table_Abstract implements
Main_Resource_User_Interface
{
    protected $_name = 'registered_users';
    protected $_primary = 'uid';
    protected $_rowClass = 'Main_Resource_User_Item';

    public function getUserById($id)
    {
        return $this->find($id)->current();
    }

    public function getUserByEmail($email, $ignoreUser=null)
    {
        $select = $this->select();
        $select->where('UserEmail = ?', $email);

        if (null !== $ignoreUser) {
            $select->where('UserEmail != ?', $ignoreUser->UserEmail);
        }
         return $this->fetchRow($select);
    }

    public function getUserByEmailPassword($email, $pwd)
    {
         $select = $this->select()->where('UserEmail = ? ', $email)
                 ->where('Password = ? ', $pwd);

         echo $select->__toString();
         
        return $this->fetchRow($select);
    }
    
    public function getUserByVerificationCode($vcode)
    {
         $select = $this->select()->where('VerificationCode = ? ', $vcode);
         return $this->fetchRow($select);
    }
    
}
?>
